<template>
  <div style="display: none"></div>
</template>

<script lang="ts" setup>
import {onBeforeUnmount, onMounted, reactive,} from 'vue';
import {useRouter} from 'vue-router'

let router = useRouter()

let timerAction: any = reactive({timer: null})

function routerGo() {
  router.push({path: `/home`,})
}

function continueAction() {
  console.log('开启定时器')
  if (timerAction.timer) {
    clearTimeout(timerAction.timer)
  }
  timerAction.timer = setTimeout(_ => {
    routerGo()
  }, platformConfig.loginToHomeTime * 1000)
}

onBeforeUnmount(() => {
  console.log('清除定时器')
  clearTimeout(timerAction.timer)
  document.onkeydown = null
  document.onmousedown = null
})

onMounted(() => {
  continueAction()
  document.onkeydown = () => {
    continueAction()
  }
  document.onmousedown = () => {
    continueAction()
  }
})
</script>